#pragma once
#include <iostream>
#include <string>
#include <sstream>
using namespace std;

class Room
{

private:
	//Uppgift 3.1
	double area;
	string type;
	int id;



public:

	Room()		//Default konstruktor
	{
		this->id = -1;
		this->area = 0;
		this->type = "";
	}

	Room(int id,double area, string type)	//Konstruktor med parametrar
	{
		this->id = id;
		this->area = area;
		this->type = type;
	}


	double GetArea() const { return this->area; }				//Getters/Setters
	void SetArea(double area) { this->area = area; }

	string GetType() const { return this->type; }
	void SetType(string type) { this->type = type; }

	int GetID() const { return this->id; }
	void SetID(int id) { this->id = id; }


	//Uppgift 3.2
	void Read()
	{
		cout << "Id: ";
		cin >> this->id;

		cout << "Area: ";
		cin >> this->area;

		cin.ignore(numeric_limits < streamsize >::max(), '\n');

		cout << "Type: ";
		getline(cin, this->type);

	}

	void Write()
	{
		cout << "Id: " << this->id << endl;
		cout << "Area: " << this->area << endl;
		cout << "Type: " << this->type << endl;
	}


	//Uppgift 3.3
	friend ostream& operator<<(ostream& out, const Room& Room)
	{
		out << "(";
		out << Room.id << ",";
		out << Room.area << ",";
		out << Room.type;
		out << ")";
		return out;
	}

	friend istream& operator>>(istream& in, Room& Room)
	{
		string s;
		getline(in, s, '(');
		getline(in, s, ',');
		istringstream iss(s);
		iss >> Room.id;

		getline(in, s, ',');
		istringstream iss2(s);
		iss2 >> Room.area;

		getline(in, Room.type, ')');
		return in;
	}

	//Uppgift 3.4

	friend bool operator==(const Room r1, const Room r2)
	{
		return r1.GetID() == r2.GetID();
	}


	

	~Room()
	{
	}
};

